﻿using System;

namespace Vkontakte.Api.Operations
{
	[ApiMethod("activity.set")]
	public sealed class ActivitySet
		: Base30ApiOperation
	{
		private long _id;

		public ActivitySet()
		{

		}

		protected override void Compile()
		{
			AddParameter("format", "json");
			AddParameter("method", "activity.set");
			if (string.IsNullOrEmpty(Text))
			{
				AddParameter("text",".");
			}else
			{
				AddParameter("text", Text);
			}

			base.Compile();
		}

		protected override void ParseData(string data)
		{
			int ptr=data.IndexOf(':');
			if (ptr!=-1)
			{
				ptr += 2;
				int end=data.IndexOf('"',ptr);
				string strId = data.Substring(ptr, end - ptr);
				_id = Convert.ToInt64(strId);
			}
			base.ParseData(data);
		}

		public string Text { get; set; }

		public long GetID()
		{
			return _id;
		}
	}
}